#include <Mesh.hpp>

Modeling::Mesh::~Mesh()
{
	for (unsigned int i=0 ; i<this->getVertQty() ; i++)
		delete this->vertex[i];

	for (unsigned int i=0 ; i<this->getMapCoordsQty() ; i++)
		delete this->mapCoord[i];

	for (unsigned int i=0 ; i<this->getPolygonsQty() ; i++)
		delete this->polygon[i];
}

Modeling::Mesh::Mesh()
{}

Modeling::Mesh::Mesh(std::string name) : Modeling::Node(name)
{}

int Modeling::Mesh::type()
{
	return Modeling::MESH;
}

void Modeling::Mesh::animate(unsigned int frame)
{}

unsigned int Modeling::Mesh::getVertQty()
{
	return this->vertex.size();
}

Vector3f* Modeling::Mesh::addVertex(Vector3f vertex)
{
	Vector3f* vert = new Vector3f(vertex);
	this->vertex.push_back(vert);
	return vert;
}

Vector3f* Modeling::Mesh::getVertex(unsigned int index)
{
	return this->vertex[index];
}

unsigned int Modeling::Mesh::getMapCoordsQty()
{
	return this->mapCoord.size();
}

Vector2f* Modeling::Mesh::addMapCoord(Vector2f mapCoord)
{
	Vector2f* coord = new Vector2f(mapCoord);
	this->mapCoord.push_back(coord);
	return coord;
}

Vector2f* Modeling::Mesh::getMapCoord(unsigned int index)
{
	return this->mapCoord[index];
}

unsigned int Modeling::Mesh::getPolygonsQty()
{
	return this->polygon.size();
}

Modeling::Polygon* Modeling::Mesh::addPolygon()
{
	Modeling::Polygon* polygon = new Modeling::Polygon();
	this->polygon.push_back(polygon);
	return polygon;
}

Modeling::Polygon* Modeling::Mesh::addPolygon(Vector3f* v1, Vector3f* v2, Vector3f* v3)
{
	Modeling::Polygon* polygon = new Modeling::Polygon(v1, v2, v3);
	this->polygon.push_back(polygon);
	return polygon;
}

Modeling::Polygon* Modeling::Mesh::getPolygon(unsigned int index)
{
	return this->polygon[index];
}
